package com.zzptc.shop.dao;

import com.zzptc.shop.db.GoodIDB;
import com.zzptc.shop.vo.Product;
import com.zzptc.shop.vo.Users;
import com.zzptc.shop.vo.VO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class GoodDao implements IDAO {
    @Override
    public boolean insert(VO vo) throws SQLException {
        return false;
    }

    @Override
    public void updata() throws SQLException {

    }

    @Override
    public boolean delete() throws SQLException {

        return false;
    }

    @Override
    public List<Users> getAll() throws SQLException {
        GoodIDB db = new GoodIDB();
        Connection conn = null;
        conn = db.getConn();
        PreparedStatement ps = conn.prepareStatement("select * from easybuy_product");
        ResultSet rs = ps.executeQuery();
        List<Product> list = new ArrayList();
        while (rs.next()) {
            Product p = new Product();
            p.setEp_id(rs.getInt(1));
            p.setEp_name(rs.getString(2));
            p.setEp_description(rs.getString(3));
            p.setEp_price(rs.getFloat(4));
            p.setEp_stock(rs.getInt(5));
            p.setEpc_id(rs.getInt(6));
            p.setEpc_child_id(rs.getInt(7));
            p.setEp_file_name(rs.getString(8));
            list.add(p);
        }
        return null;
        }}

